#ifndef __DBROLE_ENTER_FAILEDSENDER_H__
#define __DBROLE_ENTER_FAILEDSENDER_H__

#include "gwmessagemap.hpp"
#include "IMessageOperator.h"
#include "protonet.hpp"
#include "netlib.h"
#include "../DBServer.h"
#include "dbserver.pb.h"
#include "../../Sender/DBServerSender.h"

/**
*@file       DBRole_Enter_FailedSender.h
*@brief      send message DBRole_Enter_Failed
*
*@author     graywind
*@version    1.0.0.0
*@data       2012/3/28
*/

///message wrapper
class msgDBRole_Enter_Failed
{
public:
    static const int MessageId = DBRole_Enter_Failed;
    //TODO
    pnSessionHandle   SessionId;
    DBRoleEnterFailed MsgContent;
    ///@brief     constructor
    ///param[in]  session_id      identifier of the session
    ///param[in]  gate_code       code of the gateway server
    ///param[in]  error           error code
    msgDBRole_Enter_Failed(int session_id, int gate_code, EnterFailed::eErrorCode error):
    SessionId(session_id)
    {
        MsgContent.set_errorcode(error);
        MsgContent.set_gatecode(gate_code);
    }
};

class HandleDBRole_Enter_Failed
{
public:
    ///@brief     handle message
    ///param[in]  msg     message wrapper of DBRole_Enter_Failed
    ///retval     void
    static void HandleMessage(msgDBRole_Enter_Failed* msg)
    {
        //TODO
        //Main Message:  msgDBServer
        msgDBServer mainMsg(msg->SessionId, msgDBRole_Enter_Failed::MessageId, ProtoNet<DBRoleEnterFailed>::IntoBytes(msg->MsgContent));
        gwMessagePort::ProcessMessage(&mainMsg);
    }
};
///[message wrapper]  [handler]
RegisterHandler(msgDBRole_Enter_Failed, HandleDBRole_Enter_Failed);

#endif
